import { getChannelList, updateSaasCompany } from '@/api/company'

import { Modal, message } from 'ant-design-vue'
import { Component, Emit, Prop, Watch } from 'vue-facing-decorator'
import Render from '@/render/Render'
import renderModal, {
    getModelValue,
    initModelValue,
    renderForm,
    type FormModalDto
} from '@/components/modal/Modal'
import toNative from '@/utils/toNative'
import type { LongInsuranceCaseListDto, ReportCaseResultDto } from '@/api/insurance/period/types'
import Upload from '@/components/file/Upload'
@Component
export class RechargePop extends Render {
    @Prop({ default: false }) show!: boolean
    @Prop() basicInfo!: LongInsuranceCaseListDto<ReportCaseResultDto>

    fileUrl = ''

    @Emit('update:show')
    showChange(val: boolean) {
        return val
    }

    @Emit('refresh')
    handleRefresh() {}

    @Watch('show', { immediate: true })
    async handleWatchShow() {
        this.formConfig.show = this.show
        if (this.show) {
            initModelValue(this.formConfig, this.basicInfo)
        }
    }

    @Watch('formConfig.show')
    handleWatchShowDialog() {
        this.showChange(this.formConfig.show)
    }

    formConfig = this.initFormConfig() as FormModalDto
    initFormConfig() {
        return {
            title: '充值',
            theme: 'dark',
            show: false,
            params: {
                confirmText: '确定'
            },
            items: {
                amount: {
                    name: '充值金额',
                    element: 'inputNumber',
                    required: true
                },
                file: {
                    name: '上传凭证',
                    element: 'upload',
                    required: false,
                    params: {
                        autoUpload: true,
                        base64: false,
                        accept: '.png,.jpg,.jpeg',
                        hint: '大小限制5MB，支持png、jpeg、jpg格式文件'
                    }
                }
            },
            complete: async () => {
                const data = getModelValue(this.formConfig)
            },
            cancel: () => {}
        } as FormModalDto
    }

    render() {
        return (
            <>
                {renderModal(this.formConfig)}
            </>
        )
    }
}

export default toNative<{}, { refresh: () => void }>(RechargePop)
